package practice1_100;

public class Practice11 {
    //双指针法，先算起始两端的矩阵大小，收索左右指针，遇到大的就替换
    public int maxArea(int[] height) {
        int left=0;
        int right=height.length-1;
        int maxArea=0;
        while (left<right){
            if(height[left]>height[right]){
                maxArea=maxArea>height[right]*(right-left)?maxArea:height[right]*(right-left);
                right--;
            }else {
                maxArea=maxArea>height[left]*(right-left)?maxArea:height[left]*(right-left);
                left++;
            }
        }
        return maxArea;
    }

    public static void main(String[] args) {
        int a = new Practice11().maxArea(new int[]{4, 5,6,9,4,10,5,2,1,1,1,2,2,3, 2, 1, 4});
        System.out.println(a);

    }
}
